- Rmarkdown: cloned from https://github.com/micha-silver/ReLTER_demo
- Slides on website: https://micha-silver.github.io/index.html
- Youtube videos: (to be announced)
13/04/2022
New Project -> Version Control
Encourages collaboration “out of the box”.
setwd().RdataR scriptR packagesReLTER# Install some standard spatial packages from CRAN
if (!require("sf", quietly = TRUE))
install.packages("sf")
if (!require("terra", quietly = TRUE))
install.packages("terra")
# package from Bioconductor
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install()
BiocManager::install("EBImage")
# Install development package from github
if (!require("remotes", quietly = TRUE))
install.packages("remotes")
if (!require("ReLTER", quietly = TRUE))
remotes::install_github("ropensci/ReLTER")
After installing, we need to load the packages into this R session.
# Convenient way to load list of packages
pkg_list <- c("sf", "terra", "ReLTER", "tmap")
lapply(pkg_list, require, character.only = TRUE)
## [[1]] ## [1] TRUE ## ## [[2]] ## [1] TRUE ## ## [[3]] ## [1] TRUE ## ## [[4]] ## [1] TRUE
sf, terraterra, starstmap, leaflet, ggmap, (plot)Use the geodata package for sample data. Get administrative boundaries (from GADM) and monthly precipitation rasters (from WorldClim) for Slovakia.
remotes::install_github("rspatial/geodata")
library(geodata)
slv <- gadm("Slovakia", level=2, path=tempdir())
# Convert to `sf` class for plotting
slv <- st_as_sf(slv)
slv_precip <- worldclim_country("Slovakia",
var = "prec", path = tempdir())
Display the data with tmap, and use OpenStreetMaps as background.
tmap_mode("view")
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(slv) + tm_borders(col = "purple", lwd = 2) +
tm_shape(slv_precip$SVK_wc2.1_30s_prec_1) +
tm_raster(palette = "YlGnBu", alpha=0.7)
Now a different month
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(slv) + tm_borders(col = "purple", lwd = 2) +
tm_shape(slv_precip$SVK_wc2.1_30s_prec_8) +
tm_raster(palette = "YlGnBu", alpha=0.7)